// The Vue build version to load with the `import` command
// (runtime-only or standalone) has been set in webpack.base.conf with an alias.
import Vue from 'vue'
import App from './App'
import router from './router'
import ElementUI from 'element-ui'
import 'element-ui/lib/theme-chalk/index.css'
import VueAwesomeSwiper from 'vue-awesome-swiper'
import 'swiper/dist/css/swiper.css'
Vue.use(VueAwesomeSwiper, /* { default global options } */)
import store from './store'
import {getCookie} from '@/assets/js/cookie'
Vue.config.productionTip = false
import "@/assets/css/base.css"
Vue.use(ElementUI, { size: 'small', zIndex: 3000 })
/* eslint-disable no-new */

router.beforeEach((to,from,next) => {
	if(to.meta.requireAuth){
		if(!getCookie('user')){
			next({
				name: 'login',
				query: {redirect: to.fullPath}	// 将跳转的路由path作为参数，登录成功后跳转到该路由
			})
		}
		else{
			next()
		}
	}else{
		next()
	}
})
new Vue({
  el: '#app',
  router,
  store,
  components: { App },
  template: '<App/>'
})
